""" 
esp32 串口通信
设备: uart2 tx: gpio17 rx: gpio16
"""
from machine import Pin
from machine import UART

uart = UART(2,115200,rx=16,tx=17)

if __name__ == "__main__":
    uart.write("hello world")
    while True:
        if uart.any():
            buf = uart.read(128)
            print("recv: {}".format(buf))
            uart.write(buf)
